import { request } from './request.js';

/**
 * 获取预算分类列表（含消费总额）
 * @param {Number} budgetId - 预算ID
 * @param {Number} page - 页码，默认1
 * @param {Number} pageSize - 每页大小，默认10
 * @returns {Promise} - 返回请求Promise
 */
export function getBudgetCategoryList(budgetId, page = 1, pageSize = 10) {
    return request({
        url: '/budgetCategory/listWithExpense',
        method: 'GET',
        data: {
            budgetId,
            page,
            pageSize
        }
    });
}

/**
 * 添加预算分类
 * @param {Object} budgetCategory - 预算分类对象
 * @returns {Promise} - 返回请求Promise
 */
export function addBudgetCategory(budgetCategory) {
    return request({
        url: '/budgetCategory/add',
        method: 'POST',
        data: budgetCategory
    });
}

/**
 * 删除预算分类
 * @param {Number} id - 预算分类ID
 * @returns {Promise} - 返回请求Promise
 */
export function deleteBudgetCategory(id) {
    return request({
        url: `/budgetCategory/${id}`,
        method: 'DELETE'
    });
}

/**
 * 更新预算分类
 * @param {Object} budgetCategory - 预算分类对象
 * @returns {Promise} - 返回请求Promise
 */
export function updateBudgetCategory(budgetCategory) {
    return request({
        url: '/budgetCategory/update',
        method: 'POST',
        data: budgetCategory
    });
}

/**
 * 获取预算分类详情
 * @param {Number} id - 预算分类ID
 * @returns {Promise} - 返回请求Promise
 */
export function getBudgetCategoryDetail(id) {
    return request({
        url: `/budgetCategory/${id}`,
        method: 'GET'
    });
}